<style type="text/css">
	.user-lr-box-left{padding-left:0;}
	#ajax_login_form .field label{ width:120px}
</style>
<div style="width:530px; overflow:hidden;" >
	<div class="user-lr-box-left">
	<!--登录表单-->
	
			<div method="post" action="{url x="shop" r="user#dologin"}" name="ajax_login_form" id="ajax_login_form">
				<div class="field username">
					<label for="login-email-address">{$LANG.USER_TITLE_EMAIL}/{$LANG.USER_TITLE_USER_NAME}/{$LANG.MOBILE}</label>
					<input type="text" value="" class="f-input ipttxt" id="login-email-address" name="email" size="30" tabindex="1">
				</div>
				<div class="clear"></div>
				<div class="field password">
					<label for="login-password">{$LANG.USER_TITLE_USER_PWD}</label>
					<input type="password" value="" class="f-input ipttxt" id="login-password" name="user_pwd" size="30" tabindex="2">
				</div>
				<div class="clear"></div>
				{if app_conf("VERIFY_IMAGE") eq 1}
				<div class="field verify">
					<div class="verify_row">	
					<label>&nbsp;</label>							
					<input type="text" value="" class="f-input ipttxt f_l" name="verify" id="Jverify"  />	
					<img class="ml10 f_l" maxlength="4" style="margin-top:0" src="{$APP_ROOT}/verify.php?w=89&h=44&rand={function name="rand"}" onclick="this.src='{$APP_ROOT}/verify.php?w=89&h=44&rand='+ Math.random();" id="Jverify_img" title="看不清楚？换一张" />			
					</div>
				</div>
				{/if}
				<div class="field autologin clearfix" style="width:407px">
					<label class="f_l">&nbsp;</label>
					<div  class="f_l pl10 f_yahei f14" style="color:#8c8c8c">
						<span class="ui-select">
							<input type="checkbox" id="autologin" name="auto_login" value="1" tabindex="3" >
						</span>
						{$LANG.AUTO_LOGIN}
					</div>									
					<div class="lostpassword f_r">
					<a href="{url x="index" r="user#getpassword"}" class="f14 lh26 f_blue">{$LANG.FORGET_PASSWORD}</a>
					</div>
					</div>
				<div class="clear"></div>
				
				<div class="act" style="padding-left:80px">
					<input type="hidden" name="ajax" value="1">
					<input type="submit" class="login-submit-btn" id="ajax-login-submit" name="commit" value="{$LANG.LOGIN}">
					<span class="to_regsiter"><?php echo sprintf($this->_var['LANG']["REGSITER_NOW"],url("shop","user#register")); ?></span>
				</div>
				<div class="act" style="padding-left:150px">
				{function name="get_api_login"}
				</div>
		</div>
		<!--登录表单-->	
	</div>
</div>	
<script type="text/javascript">
	$(document).ready(function(){
		var remenber_i=1;	
		$(".ui-select").click(function(){
				if(remenber_i == 0){
					remenber_i = 1;
					$(this).removeClass("ui-selected");
					$("#autologin").attr("checked","");
				}
				else{
					remenber_i = 0;
					$(this).addClass("ui-selected");
					$("#autologin").attr("checked","checked");
				}
			});
			$("#ajax-login-submit").click(function(){
				ajaxCheckLogin()
			});	
			
			$("#ajax_login_form input,#ajax_login_form select").keydown(function(e){ 
				var curKey = e.which; 
				if(curKey == 13){
					ajaxCheckLogin();
				} 
			});
	});
		
		function ajaxCheckLogin(){
			
				if($.trim($("#login-email-address").val()).length == 0)
				{
					$.showErr("{function name="sprintf" format=$LANG.FORMAT_ERROR_TIP value=$LANG.USER_TITLE_EMAIL}{$LANG.OR}{function name="sprintf" format=$LANG.FORMAT_ERROR_TIP value=$LANG.USER_TITLE_USER_NAME}");
					$("#login-email-address").focus();
					return false;
				}
		
				if(!$.minLength($("#login-password").val(),4,false))
				{
					$.showErr("{function name="sprintf" format=$LANG.FORMAT_ERROR_TIP value=$LANG.USER_TITLE_USER_PWD}");
					$("#login-password").focus();
					return false;
				}
				
				var ajaxurl = $("div[name='ajax_login_form']").attr("action");
				var query = new Object();
				query.email = $("div[name='ajax_login_form'] #login-email-address").val();
				query.user_pwd = $("div[name='ajax_login_form'] #login-password").val();
				
				if($("#Jverify").length > 0)
					query.verify = $("#Jverify").val();
				query.auto_login = $("div[name='ajax_login_form'] #autologin").val();
				query.ajax = 1;

				$.ajax({ 
					url: ajaxurl,
					dataType: "json",
					data:query,
					type: "POST",
					success: function(ajaxobj){
						if(ajaxobj.status==0)
						{
							if($("#Jverify_img").length > 0)
								$("#Jverify_img").attr("src",'{$APP_ROOT}/verify.php?w=89&h=44&rand='+ Math.random());
							$.showErr(ajaxobj.info);	
						}
						else
						{
							var integrate = $("<span id='integrate'>"+ajaxobj.data+"</span>");
							$("body").append(integrate);														
							close_pop();
							
							update_user_tip();
							
							$("#integrate").remove();
							if(ajaxobj.status==1){
								$.showSuccess(ajaxobj.info,function(){
									window.location.reload();
								});
							}
							else{
								$.showCfm(ajaxobj.info,function(){
									location.href = ajaxobj.jump1;
								},function(){
									window.location.reload();
								});
							}					
						}
					},
					error:function(ajaxobj)
					{
//						if(ajaxobj.responseText!='')
//						alert(ajaxobj.responseText);
					}
				});	
				
				return false;
		}

		function update_user_tip()
		{
			var ajaxurl = APP_ROOT+"/index.php?ctl=ajax&act=update_user_tip";
			$.ajax({ 
			url: ajaxurl,
			type: "POST",
			success: function(ajaxobj){
				$("#user_head_tip").html(ajaxobj);
			},
			error:function(ajaxobj)
			{
//				if(ajaxobj.responseText!='')
//				alert(ajaxobj.responseText);
			}
		});	
		}
</script>
